Skip to main content
This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum


  

PreviousPrevious NextNext

RE: Determine dates - how?
~Bill Quetfoochekakol 26.Jan.04 07:26 PM a Web browser
Domino Designer 6.0.3 Windows 2000, Windows XP


Try this function

Function weekdayN(Byval monthDate As Variant, Byval n As Integer, Byval dayOfWeek As Integer) As Variant
' returns a DateTime variant, in the same month as monthDate, that is the n'th dayOfWeek day on or after the first of the month.
' monthdate is a DateTime variant, that is within the month.
' n is the week counter
' dayOfWeek is the weekday that is required (sunday = 1, saturday = 7)
Dim theDate As Variant
Dim dayAdjust As Integer
theDate = Cdat(Int(monthDate) - Day(monthDate) + 1) ' removes time part, and adjusts to first of month
theDate = theDate + 7 * (n - 1) ' adjust by n full weeks - 1
dayAdjust = dayOfWeek - Weekday(theDate) ' number of days to reach dayOfWeek
If dayAdjust < 0 Then dayAdjust = dayAdjust + 7 ' make certain that date is adjusted forward in time
theDate = Cdat(theDate + dayAdjust)
weekDayN = theDate
End Function


example of use:
Dim d As Variant
d = weekdayN(Today, 3, 4) ' returns the date of the third wednesday of the current month (4 = wednesday)
Print Format(d, "dddd ") & Format(d, "Long Date")

Note that no check is made whether the date returned is within the month requested. So if you ask for the sixth thursday of january, it returns a date in february.




Determine dates - how? (~Mark Refoopulo... 26.Jan.04)
. . RE: Determine dates - how? (~Bill Quetfooch... 26.Jan.04)
. . . . RE: Determine dates - how? (~Mark Refoopulo... 27.Jan.04)


Document Options






  Document options
Print this pagePrint this page

Search this forum

Forum views and search


  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Category
Platform
Release
Advanced search

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS